/*
 * @(#)ActionInvocationHelper.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.xwork;

import java.util.Map;

import com.opensymphony.xwork.ActionInvocation;

/**
 * {@link ActionInvocation} Helper.
 *
 * @author Web Platform Development Team
 */
@SuppressWarnings("unchecked")
public class ActionInvocationHelper {
    /**
     * key about datamap of usf
     */
    public static final String KEY_USF_DATA_STRUCTURE = "usf_data_structure";

    @Deprecated
    public static final String KEY_USF_DATA_MAP = KEY_USF_DATA_STRUCTURE;

    /**
     * extract datamap from {@link ActionInvocation}.
     * 
     * @param actionInvocation the ActionInvocation
     * @return the usf data structure
     */
    public static Map<String, Object> getDataMap(ActionInvocation actionInvocation) {
        return (Map<String, Object>)actionInvocation.getInvocationContext().get(KEY_USF_DATA_STRUCTURE);
    }

    /**
     * Adds the data map.
     *
     * @param actionInvocation the action invocation
     * @param dataMap          the data map
     */
    public static void addDataMap(ActionInvocation actionInvocation, Map<String, Object> dataMap) {
        getDataMap(actionInvocation).putAll(dataMap);
    }
}
